<?php
namespace app\apiadmin\service\system;
use think\facade\Db;
class ManagerService
{
    private static $_qiyeid =1;
    private static $_role_id=7;//小雪花角色id

    public static function add_manager($param){
        if(!$param['zhujiao_group_id']){
            return false;
        }
        //添加小雪花管理员账号
        $data=[
            'qiyeid'=>self::$_qiyeid,
            'account'=>$param['user_name'],
            'nick'=>$param['nick_name'],
            'password'=>$param['password'],
            'role_id'=>self::$_role_id,
            'time'=>date('Y-m-d H:i:s', time()),
            'remark'=>'私欲平台账号同步添加'
        ];
        $manager_res = Db::table('xh_manager')->save($data);
        //添加助教组
        $data=[
            'userid'=>$param['user_name'],
            'groupid'=>$param['zhujiao_group_id'],
            'time'=>date('Y-m-d H:i:s', time())
        ];
        $group_res = Db::table('xh_zhujiao_group_list')->save($data);
        if($manager_res && $group_res){
            return true;
        }
        return false;
    }


    /**
     * 根据科目获取平台id数组
     * @param mixed $keMu
     * @return array
     */
    public static function getPingTaiByKeMu($keMu){

        $map = [];
        $map[] =  ['del', '=', 0];
        if($keMu>0){
            $map[] =  ['kemu', '=', $keMu];
        }
        
        $data2 = Db::table('xh_order_pingtai')->where($map)->select()->toArray();

        $data = array_column($data2,'id');

        return $data;
    }


    
}